<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>协会概况--->详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${ctxPath}/static/manage/css/x-admin.css" media="all">
    <link rel="stylesheet" href="${ctxPath}/static/manage/layui/css/layui.css" media="all">
    <script src="${ctxPath}/static/manage/js/jquery.js"></script>
    <script src="${ctxPath}/static/manage/layui/layui.js"></script>
    <script src="${ctxPath}/static/manage/js/x-layui.js" charset="utf-8"></script>
</head>
<body>
<form class="layui-form" id="formUpdateFlowers">
    <br>
    <div class="layui-form-item">
        <div class="layui-input-inline">
            <input type="hidden" name="id" class="layui-input" value="${flowers.id}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">花卉名称:</label>
        <div class="layui-input-inline">
            <input type="text" name="name" class="layui-input" value="${flowers.name}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">花卉颜色:</label>
        <div class="layui-input-inline">
           <input type="text" name="color" class="layui-input" value="${flowers.color}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">花卉属性:</label>
        <div class="layui-input-inline">
            <input type="text" name="fproperty" class="layui-input" value="${flowers.fproperty}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">花卉详情:</label>
        <div class="layui-input-inline">
            <input type="text" name="detail" class="layui-input" value="${flowers.detail}"/>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">花卉图片:</label>
        <div class="layui-input-inline">
            <input type="text" name="image" class="layui-input" value="${flowers.image}"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">花卉类别:</label>
        <div class="layui-input-inline">
            <select id="fid" name="fid">
                <option value="${flowers.fid}"></option>
            </select>
        </div>
    </div>
    <div class="layui-input-block">
        <button class="layui-btn" lay-submit lay-filter="updateFlowers">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary" lay-filter="closeBtn">重置</button>
    </div>
</form>
</body>
</html>
<script type="text/javascript">
    layui.use(['form','layer','upload'], function() {
        var $ = layui.$, form = layui.form, upload = layui.upload, layer = layui.layer;
        // 监听提交
        form.on('submit(updateFlowers)', function (obj) {
                $.ajax({
                    url: '/manage/flowers/flowersUpdate',
                    type: 'post',
                    data: obj.field,
                    success: function (result) {
                        alert(result);
                        window.parent.location.reload();
                    }
                });
            return false;
        });
        //退出按钮
        form.on("submit(closeBtn)",function (data) {
            window.parent.location.reload();
        })

        //类型下拉框内容
        $(function (){
            //获取到fid的值
            var id = $("#fid").val();
            $.ajax({
                url: '/manage/flowerType/selectFType',
                type: 'post',
                data: {},
                dataType: 'json',
                success: function (res) {
                      if(res.length>0){
                          for (var i = 0; i < res.length; i++) {
                              if(id==res[i].fid){
                                  $("#fid").append("<option value='" + res[i].fid + "' selected='selected'>" + res[i].fname + "</option>");
                              }else{
                                  $("#fid").append("<option value='" + res[i].fid + "'>" + res[i].fname + "</option>");
                              }
                              form.render();
                          }
                      }

                }
            })
        })
    })
</script>